package com.mhkj.base.busiMode.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.mhkj.base.busiMode.entity.BusiModel;
import com.mhkj.base.busiMode.service.BusiModelService;
import com.mhkj.base.busiType.service.BusinessTypeService;
import com.mics.core.common.componet.Pagination;
import com.mics.core.common.componet.ResponseMessage;
import com.mics.core.system.base.controller.BaseController;
import com.mics.core.system.organizational.bean.Employee;
import com.mics.core.system.organizational.service.OrgService;
import com.mics.core.system.rbac.entity.Dictionary;
import com.mics.core.system.rbac.service.DictionaryService;

/**
 * 业务系统模块分类
 * 
 * @author mics
 * @date 2018年7月9日
 * @version 1.0
 */
@RestController
@RequestMapping("/busiModel")
public class BusiModelController extends BaseController<BusiModel> {
	@Resource
	private BusiModelService busiModelService;
	@Resource
	private BusinessTypeService businessTypeService;
	@Resource
	private DictionaryService dictionaryService;
	@Resource
	private OrgService orgService;

	@Resource
	public void setBusiModelService(BusiModelService busiModelService) {
		super.setBaseService(busiModelService);
	}

	/**
	 * 分页查询
	 * 
	 * @author mics
	 * @date 2018年7月9日
	 * @version 1.0
	 */
	@RequestMapping("/listByPage")
	public Pagination<BusiModel> listByPage(BusiModel busiModel, int pageIndex, int pageSize) {
		Pagination<BusiModel> pagination = busiModelService.listByPage(busiModel, pageIndex, pageSize);
		return pagination;
	}

	@Override
	@RequestMapping("/save")
	public ResponseMessage save(BusiModel t) {
		return super.save(t);
	}

	@Override
	@RequestMapping("/edit")
	public ResponseMessage edit(BusiModel t) {
		return super.edit(t);
	}

	@Override
	@RequestMapping("/del")
	public ResponseMessage del(BusiModel t) {
		return super.del(t);
	}

	@Override
	@RequestMapping("/info")
	public BusiModel info(long id) {
		BusiModel busiModel = super.info(id);
		Dictionary busiSys = dictionaryService.getById(busiModel.getBusiSysId());
		busiModel.setBusiSysName(busiSys.getName());
		Dictionary phase = dictionaryService.getById(busiModel.getPhaseId());
		busiModel.setPhaseName(phase.getName());
		Employee creEmployee = orgService.employeeInfo(busiModel.getCreateBy());
		busiModel.setCreateUserName(creEmployee.getName());
		return busiModel;
	}

	@RequestMapping("/listAll")
	@ResponseBody
	public List<BusiModel> listAll() {
		return busiModelService.findAll();
	}
}
